/**************************************************************
    My Database Connection Pool
***************************************************************/
package linuxbox.util;

import java.util.*;
import linuxbox.BoxStatic;

public class ObjectWrapper {
    private Object obj;
    private long expireTime;
    
    public static ObjectWrapper getInstance(Object obj) {
        return new ObjectWrapper(obj, -1);
    }

    public static ObjectWrapper getInstance(Object obj, long eTime) {
        return new ObjectWrapper(obj, eTime);
    }
    
    private ObjectWrapper(Object obj, long eTime) {
        this.obj = obj;
        this.expireTime = eTime;
    }
    
    public Object getObject() {
        return obj;
    }

    public long getExpireTime() {
        return expireTime;
    }

    public void setObject(Object obj) {
        this.obj = obj;
    }

    public void setExpireTime(long eTime) {
        this.expireTime = eTime;
    }

    public boolean checkExpire(long now) {
        if (expireTime == -1) return false;
        
        if (now > expireTime) {
            return true;
        } else {
            return false;
        }
    }
}
